<template>
    <!-- 技术-技术月报=双优化未实施情况 -->
    <base-breadcrumb :title="$route.meta.title">
        <!-- 搜索 -->
        <searchData :searchData="searchArr" @search="search"></searchData>
        <!-- 表格 -->
        <a-card :bordered="false">
            <!-- <title-name :title="$route.meta.title"></title-name> -->
            <a-button class="mb12" icon="plus" type="primary" @click="handleManage(2)" v-btnPermission="'tm_034_add_01'">新增</a-button>
            <!-- 表格 -->
            <list-table
                ref="table"
                tableLayout="fixed"
                size="default"
                rowKey="id"
                :columns="columns"
                :request="loadData"
                :page-keys="['pageNo', 'pageSize','totalSize']"
                :alert="true"
                show-size-changer
                show-quick-jumper
                showPagination="auto">
                <template slot="action" slot-scope="text, record">
                    <MoreButton>
                    <a @click="handleManage(0, record)">查看</a>
                    <span v-btnPermission="'tm_034_edi_02'" v-if="record.chooseEdit*1===1">
                        <a-divider type="vertical" />
                        <a @click="handleManage(1, record)">编辑</a>
                     </span>
                     <span v-btnPermission="'tm_034_del_03'">
                        <a-divider type="vertical"></a-divider>
                        <a @click="handleRemoveParams({ id: record.id })">删除</a>
                    </span>
                    </MoreButton>
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { getWorkScheduleList, delWorkScheduleList} from '@/api/technical/workArrangementPlan' // api
import BasePage from '@/views/basePage' // 基础配置
import SelectCompanyAndProject from '@/components/Select/SelectCompanyAndProject'
import OrgTreeSelect from '@/components/OrgTreeSelect'
import Item from '@/components/AvatarList/Item.vue'
const searchArr = [
    // 搜索框
    // {name: '单位名称',valueKey: 'branchComId',type: SelectCompanyAndProject,},
    {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
    {name: '月份',value: 'nextMonth',type: 'month'},
    {name: '计划工作内容',type: 'input', value: 'content'},
    {name: '填报人',type: 'input',value: 'creatorName'},
    {name: '填报时间',type: 'dateRange',value: 'createTime',
        attr: {
            rangeFormat: ['dateBegin', 'dateEnd']
        }
    },
]

const columns = [
    {title: '序号',width: 80,dataIndex: 'index',
        customRender() {
            return arguments[2] + 1
        }
    },
    {title: '单位名称',dataIndex: 'branchComName',ellipsis: true,width: 250,},
    {title: '计划月份',dataIndex: 'nextMonth',ellipsis: true,width: 150,},
    {title: '计划工作内容',dataIndex: 'content',ellipsis: true,width: 300,},
    {title: '填报人',dataIndex: 'creatorName',ellipsis: true,},
    {title: '填报时间',dataIndex: 'createTime',ellipsis: true,width: 150,},
    {title: '操作',dataIndex: 'action',width: '280px',align: 'center',scopedSlots: { customRender: 'action' },}
]
export default {
    name: 'a' + Date.now(),
    extends: new BasePage(),
    components: {
        STable,
        Item
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {}, // 查询参数
            loadData: async (parameter) => {
                const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
                return getWorkScheduleList(requestParameters).then((res) => {
                 return res;
                })
            },
            removeApi: { remove: delWorkScheduleList},// api
        }
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            let query = {
                editModel: type
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: 'updateWorkArrangementPlan',
                query
            })
        }
    },
   created(){
    }
}
</script>
